(function () {
    var serverData = {};
    var serverTable;//合同列表
    jQuery(document).ready(function () {
    	serverTable = jQuery('#dataTable').DataTable({
            "serverSide": true,
            "ordering": false,
            "ajax": {
                "dataType": "json",
                "type": "post",
                "cache": false,
                "url":window.rootPath+ '/ui/viPCAssInstructionExcuteWithPlanView/getpage1',
                "data": function (d) {
                    return $.extend({}, d, serverData);
                }
            },
            columns: [
                {
                	data: null
                },
                {
    	            data: null,
    	            defaultContent: "",
    	            render: function (data, type, full, meta) {
    	            	var id=data.id
    	            	var operate ='<input type="checkbox" class="checkchildContract">';
    	            	return operate;
    	            }   
                },
                {
                    data: 'cExcutePlanNumber'
                },
                {
                	data: 'cContractNum'
                },
                {
               	 data: 'cModel',
                },
                {
                	data: 'cBTPart'
                },
                {
                    data: 'cEqNo'
                },
                {
                    data: 'cType'
                },
                {
                    data: 'cProcess',
                },
                {
                    data: 'cState',
                },
                {
                    data: 'cPlanState',
                },
                {
                    data: 'dBeginCollarDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dEndCollarDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'cCollarMemo',
                },
                {
                    data: 'dTaskAcceptAssDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dTaskSubmitAssDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'cTaskAssMemo'
                },
                {
                    data: 'dBeginAssDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dEndAssDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'cAssMemo'
                },
                {
                    data: 'dTaskAcceptWaterTestDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dTaskSubmitWaterTestDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dBeginWaterTestDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dEndWaterTestDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'cWaterTestMemo'
                },
                {
                    data: 'dTaskAcceptPaintDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dTaskSubmitPaintDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'cTasktPaintMemo'
                },
                {
                    data: 'dBeginPaintDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dEndPaintDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'cPaintMemo'
                },
                {
                    data: 'dTaskAcceptSealingDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dTaskSubmitSealingDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'cTaskSealingMemo'
                },
                {
                    data: 'dBeginSealingDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'dEndSealingDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },
                {
                    data: 'cSealingMemo'
                },{
                    data: 'dTaskAcceptStorageDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },{
                    data: 'dTaskSubmitStorageDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },{
                    data: 'cTaskStorageMemo'
                },{
                    data: 'dBeginStorageDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },{
                    data: 'dEndStorageDate',
                    render: function (data, type, full, meta) {
                        if (data)
                            return moment(data).format('YYYY/MM/DD');
                        else
                            return '';
                    }
                },{
                    data: 'cStorageMemo'
                }
                ],
            "drawCallback": function (oSettings) {
                var k = 0;
                var total = oSettings.aiDisplay.length + oSettings._iDisplayStart;

                for (var i = oSettings._iDisplayStart, iLen = total; i < iLen; i++) {
                    $('td:eq(0)', oSettings.aoData[oSettings.aiDisplay[k]].nTr).text(i + 1);
                    k++;
                }
            }
        });
    });
    /**
     * 查询按钮
     */
	jQuery('.searchBtn').on('click',function(){
    	getServerDate();
    	serverTable.draw();
    	//clearQueryServerData();
    })
    /**
     * 撤销查询
     */
    jQuery('.resetBtn').on("click",function()
        {
        	clearQueryServerData('clearui');
            serverTable.draw();
        });
    var getServerDate=function(){
		if(jQuery("#cExcutePlanNumber").val()) serverData.cExcutePlanNumber=jQuery("cExcutePlanNumber").val();
		if(jQuery("#cContractNum").val()) serverData.cContractNum=jQuery("cContractNum").val();
		if(jQuery("#cModel").val()) serverData.cModel=jQuery("cModel").val();
		if(jQuery("#cBTPart").val()) serverData.cBTPart=jQuery("cBTPart").val();
		if(jQuery("#cEqNo").val()) serverData.cEqNo=jQuery("cEqNo").val();
		if(jQuery("#cType").val()) serverData.cType=jQuery("cType").val();
		if(jQuery("#cProcess").val()) serverData.cProcess=jQuery("cProcess").val();
		if(jQuery("#cState").val()) serverData.cState=jQuery("cState").val();
		if(jQuery("#cPlanState").val()) serverData.cPlanState=jQuery("cPlanState").val();
		
		if(jQuery("#dBeginCollarDateStartDate").val()) serverData.dBeginCollarDateStartDate=jQuery("dBeginCollarDateStartDate").val();
		if(jQuery("#dBeginCollarDateEndDate").val()) serverData.dBeginCollarDateEndDate=jQuery("dBeginCollarDateEndDate").val();
		
		if(jQuery("#dEndCollarDateStartDate").val()) serverData.dEndCollarDateStartDate=jQuery("dEndCollarDateStartDate").val();
		if(jQuery("#dEndCollarDateEndDate").val()) serverData.dEndCollarDateEndDate=jQuery("dEndCollarDateEndDate").val();
		
		if(jQuery("#cCollarMemo").val()) serverData.cCollarMemo=jQuery("cCollarMemo").val();
		
		if(jQuery("#dTaskAcceptAssDateStartDate").val()) serverData.dTaskAcceptAssDateStartDate=jQuery("dTaskAcceptAssDateStartDate").val();
		if(jQuery("#dTaskAcceptAssDateEndDate").val()) serverData.dTaskAcceptAssDateEndDate=jQuery("dTaskAcceptAssDateEndDate").val();
		
		if(jQuery("#dTaskSubmitAssDateStartDate").val()) serverData.dTaskSubmitAssDateStartDate=jQuery("dTaskSubmitAssDateStartDate").val();
		if(jQuery("#dTaskSubmitAssDateEndDate").val()) serverData.dTaskSubmitAssDateEndDate=jQuery("dTaskSubmitAssDateEndDate").val();
		
		if(jQuery("#cTaskAssMemo").val()) serverData.cTaskAssMemo=jQuery("cTaskAssMemo").val();
		
		if(jQuery("#dBeginAssDateStartDate").val()) serverData.dBeginAssDateStartDate=jQuery("dBeginAssDateStartDate").val();
		if(jQuery("#dBeginAssDateEndDate").val()) serverData.dBeginAssDateEndDate=jQuery("dBeginAssDateEndDate").val();
		
		if(jQuery("#dEndAssDateStartDate").val()) serverData.dEndAssDateStartDate=jQuery("dEndAssDateStartDate").val();
		if(jQuery("#dEndAssDateEndDate").val()) serverData.dEndAssDateEndDate=jQuery("dEndAssDateEndDate").val();
		
		if(jQuery("#cAssMemo").val()) serverData.cAssMemo=jQuery("cAssMemo").val();
		
		if(jQuery("#dTaskAcceptWaterTestDateStartDate").val()) serverData.dTaskAcceptWaterTestDateStartDate=jQuery("dTaskAcceptWaterTestDateStartDate").val();
		if(jQuery("#dTaskAcceptWaterTestDateEndDate").val()) serverData.dTaskAcceptWaterTestDateEndDate=jQuery("dTaskAcceptWaterTestDateEndDate").val();
		
		if(jQuery("#dTaskSubmitWaterTestDateStartDate").val()) serverData.dTaskSubmitWaterTestDateStartDate=jQuery("dTaskSubmitWaterTestDateStartDate").val();
		if(jQuery("#dTaskSubmitWaterTestDateEndDate").val()) serverData.dTaskSubmitWaterTestDateEndDate=jQuery("dTaskSubmitWaterTestDateEndDate").val();
		
		if(jQuery("#cTaskWaterTestMemo").val()) serverData.cTaskWaterTestMemo=jQuery("cTaskWaterTestMemo").val();
		
		if(jQuery("#dBeginWaterTestDateStartDate").val()) serverData.dBeginWaterTestDateStartDate=jQuery("dBeginWaterTestDateStartDate").val();
		if(jQuery("#dBeginWaterTestDateEndDate").val()) serverData.dBeginWaterTestDateEndDate=jQuery("dBeginWaterTestDateEndDate").val();
		
		if(jQuery("#dEndWaterTestDateStartDate").val()) serverData.dEndWaterTestDateStartDate=jQuery("dEndWaterTestDateStartDate").val();
		if(jQuery("#dEndWaterTestDateEndDate").val()) serverData.dEndWaterTestDateEndDate=jQuery("dEndWaterTestDateEndDate").val();
		
		if(jQuery("#cWaterTestMemo").val()) serverData.cWaterTestMemo=jQuery("cWaterTestMemo").val();
		
		if(jQuery("#dTaskAcceptPaintDateStartDate").val()) serverData.dTaskAcceptPaintDateStartDate=jQuery("dTaskAcceptPaintDateStartDate").val();
		if(jQuery("#dTaskAcceptPaintDateEndDate").val()) serverData.dTaskAcceptPaintDateEndDate=jQuery("dTaskAcceptPaintDateEndDate").val();
		
		if(jQuery("#dTaskSubmitPaintDateStartDate").val()) serverData.dTaskSubmitPaintDateStartDate=jQuery("dTaskSubmitPaintDateStartDate").val();
		if(jQuery("#dTaskSubmitPaintDateEndDate").val()) serverData.dTaskSubmitPaintDateEndDate=jQuery("dTaskSubmitPaintDateEndDate").val();
		
		if(jQuery("#cTasktPaintMemo").val()) serverData.cTasktPaintMemo=jQuery("cTasktPaintMemo").val();
		
		if(jQuery("#dBeginPaintDateStartDate").val()) serverData.dBeginPaintDateStartDate=jQuery("dBeginPaintDateStartDate").val();
		if(jQuery("#dBeginPaintDateEndDate").val()) serverData.dBeginPaintDateEndDate=jQuery("dBeginPaintDateEndDate").val();
		
		if(jQuery("#dEndPaintDateStartDate").val()) serverData.dEndPaintDateStartDate=jQuery("dEndPaintDateStartDate").val();
		if(jQuery("#dEndPaintDateEndDate").val()) serverData.dEndPaintDateEndDate=jQuery("dEndPaintDateEndDate").val();
		
		if(jQuery("#cPaintMemo").val()) serverData.cPaintMemo=jQuery("cPaintMemo").val();
		
		if(jQuery("#dTaskAcceptSealingDateStartDate").val()) serverData.dTaskAcceptSealingDateStartDate=jQuery("dTaskAcceptSealingDateStartDate").val();
		if(jQuery("#dTaskAcceptSealingDateEndDate").val()) serverData.dTaskAcceptSealingDateEndDate=jQuery("dTaskAcceptSealingDateEndDate").val();
		
		if(jQuery("#dTaskSubmitSealingDateStartDate").val()) serverData.dTaskSubmitSealingDateStartDate=jQuery("dTaskSubmitSealingDateStartDate").val();
		if(jQuery("#dTaskSubmitSealingDateEndDate").val()) serverData.dTaskSubmitSealingDateEndDate=jQuery("dTaskSubmitSealingDateEndDate").val();
		
		if(jQuery("#cTaskSealingMemo").val()) serverData.cTaskSealingMemo=jQuery("cTaskSealingMemo").val();
		
		if(jQuery("#dBeginSealingDateStartDate").val()) serverData.dBeginSealingDateStartDate=jQuery("dBeginSealingDateStartDate").val();
		if(jQuery("#dBeginSealingDateEndDate").val()) serverData.dBeginSealingDateEndDate=jQuery("dBeginSealingDateEndDate").val();
		
		if(jQuery("#dEndSealingDateStartDate").val()) serverData.dEndSealingDateStartDate=jQuery("dEndSealingDateStartDate").val();
		if(jQuery("#dEndSealingDateEndDate").val()) serverData.dEndSealingDateEndDate=jQuery("dEndSealingDateEndDate").val();
		
		if(jQuery("#cSealingMemo").val()) serverData.cSealingMemo=jQuery("cSealingMemo").val();
		
		if(jQuery("#dTaskAcceptStorageDateStartDate").val()) serverData.dTaskAcceptStorageDateStartDate=jQuery("dTaskAcceptStorageDateStartDate").val();
		if(jQuery("#dTaskAcceptStorageDateEndDate").val()) serverData.dTaskAcceptStorageDateEndDate=jQuery("dTaskAcceptStorageDateEndDate").val();
		
		if(jQuery("#dTaskSubmitStorageDateStartDate").val()) serverData.dTaskSubmitStorageDateStartDate=jQuery("dTaskSubmitStorageDateStartDate").val();
		if(jQuery("#dTaskSubmitStorageDateEndDate").val()) serverData.dTaskSubmitStorageDateEndDate=jQuery("dTaskSubmitStorageDateEndDate").val();
		
		if(jQuery("#cTaskStorageMemo").val()) serverData.cTaskStorageMemo=jQuery("cTaskStorageMemo").val();
		
		if(jQuery("#dBeginStorageDateStartDate").val()) serverData.dBeginStorageDateStartDate=jQuery("dBeginStorageDateStartDate").val();
		if(jQuery("#dBeginStorageDateEndDate").val()) serverData.dBeginStorageDateEndDate=jQuery("dBeginStorageDateEndDate").val();
		
		if(jQuery("#dEndStorageDateStartDate").val()) serverData.dEndStorageDateStartDate=jQuery("dEndStorageDateStartDate").val();
		if(jQuery("#dEndStorageDateEndDate").val()) serverData.dEndStorageDateEndDate=jQuery("dEndStorageDateEndDate").val();
		
		if(jQuery("#cStorageMemo").val()) serverData.cStorageMemo=jQuery("cStorageMemo").val();
	}
    var clearQueryServerData=function(option){
    	/*if(option=='clearui'){
    		 jQuery('input').val('');
             jQuery('select').val('');
    	}*/
    	if(jQuery("#cExcutePlanNumber").val()) serverData.cExcutePlanNumber=null;
		if(jQuery("#cContractNum").val()) serverData.cContractNum=null;
		if(jQuery("#cModel").val()) serverData.cModel=null;
		if(jQuery("#cBTPart").val()) serverData.cBTPart=null;
		if(jQuery("#cEqNo").val()) serverData.cEqNo=null;
		if(jQuery("#cType").val()) serverData.cType=null;
		if(jQuery("#cProcess").val()) serverData.cProcess=null;
		if(jQuery("#cState").val()) serverData.cState=null;
		if(jQuery("#cPlanState").val()) serverData.cPlanState=null;
		
		if(jQuery("#dBeginCollarDateStartDate").val()) serverData.dBeginCollarDateStartDate=null;
		if(jQuery("#dBeginCollarDateEndDate").val()) serverData.dBeginCollarDateEndDate=null;
		
		if(jQuery("#dEndCollarDateStartDate").val()) serverData.dEndCollarDateStartDate=null;
		if(jQuery("#dEndCollarDateEndDate").val()) serverData.dEndCollarDateEndDate=null;
		
		if(jQuery("#cCollarMemo").val()) serverData.cCollarMemo=null;
		
		if(jQuery("#dTaskAcceptAssDateStartDate").val()) serverData.dTaskAcceptAssDateStartDate=null;
		if(jQuery("#dTaskAcceptAssDateEndDate").val()) serverData.dTaskAcceptAssDateEndDate=null;
		
		if(jQuery("#dTaskSubmitAssDateStartDate").val()) serverData.dTaskSubmitAssDateStartDate=null;
		if(jQuery("#dTaskSubmitAssDateEndDate").val()) serverData.dTaskSubmitAssDateEndDate=null;
		
		if(jQuery("#cTaskAssMemo").val()) serverData.cTaskAssMemo=null;
		
		if(jQuery("#dBeginAssDateStartDate").val()) serverData.dBeginAssDateStartDate=null;
		if(jQuery("#dBeginAssDateEndDate").val()) serverData.dBeginAssDateEndDate=null;
		
		if(jQuery("#dEndAssDateStartDate").val()) serverData.dEndAssDateStartDate=null;
		if(jQuery("#dEndAssDateEndDate").val()) serverData.dEndAssDateEndDate=null;
		
		if(jQuery("#cAssMemo").val()) serverData.cAssMemo=null;
		
		if(jQuery("#dTaskAcceptWaterTestDateStartDate").val()) serverData.dTaskAcceptWaterTestDateStartDate=null;
		if(jQuery("#dTaskAcceptWaterTestDateEndDate").val()) serverData.dTaskAcceptWaterTestDateEndDate=null;
		
		if(jQuery("#dTaskSubmitWaterTestDateStartDate").val()) serverData.dTaskSubmitWaterTestDateStartDate=null;
		if(jQuery("#dTaskSubmitWaterTestDateEndDate").val()) serverData.dTaskSubmitWaterTestDateEndDate=null;
		
		if(jQuery("#cTaskWaterTestMemo").val()) serverData.cTaskWaterTestMemo=null;
		
		if(jQuery("#dBeginWaterTestDateStartDate").val()) serverData.dBeginWaterTestDateStartDate=null;
		if(jQuery("#dBeginWaterTestDateEndDate").val()) serverData.dBeginWaterTestDateEndDate=null;
		
		if(jQuery("#dEndWaterTestDateStartDate").val()) serverData.dEndWaterTestDateStartDate=null;
		if(jQuery("#dEndWaterTestDateEndDate").val()) serverData.dEndWaterTestDateEndDate=null;
		
		if(jQuery("#cWaterTestMemo").val()) serverData.cWaterTestMemo=null;
		
		if(jQuery("#dTaskAcceptPaintDateStartDate").val()) serverData.dTaskAcceptPaintDateStartDate=null;
		if(jQuery("#dTaskAcceptPaintDateEndDate").val()) serverData.dTaskAcceptPaintDateEndDate=null;
		
		if(jQuery("#dTaskSubmitPaintDateStartDate").val()) serverData.dTaskSubmitPaintDateStartDate=null;
		if(jQuery("#dTaskSubmitPaintDateEndDate").val()) serverData.dTaskSubmitPaintDateEndDate=null;
		
		if(jQuery("#cTasktPaintMemo").val()) serverData.cTasktPaintMemo=null;
		
		if(jQuery("#dBeginPaintDateStartDate").val()) serverData.dBeginPaintDateStartDate=null;
		if(jQuery("#dBeginPaintDateEndDate").val()) serverData.dBeginPaintDateEndDate=null;
		
		if(jQuery("#dEndPaintDateStartDate").val()) serverData.dEndPaintDateStartDate=null;
		if(jQuery("#dEndPaintDateEndDate").val()) serverData.dEndPaintDateEndDate=null;
		
		if(jQuery("#cPaintMemo").val()) serverData.cPaintMemo=null;
		
		if(jQuery("#dTaskAcceptSealingDateStartDate").val()) serverData.dTaskAcceptSealingDateStartDate=null;
		if(jQuery("#dTaskAcceptSealingDateEndDate").val()) serverData.dTaskAcceptSealingDateEndDate=null;
		
		if(jQuery("#dTaskSubmitSealingDateStartDate").val()) serverData.dTaskSubmitSealingDateStartDate=null;
		if(jQuery("#dTaskSubmitSealingDateEndDate").val()) serverData.dTaskSubmitSealingDateEndDate=null;
		
		if(jQuery("#cTaskSealingMemo").val()) serverData.cTaskSealingMemo=null;
		
		if(jQuery("#dBeginSealingDateStartDate").val()) serverData.dBeginSealingDateStartDate=null;
		if(jQuery("#dBeginSealingDateEndDate").val()) serverData.dBeginSealingDateEndDate=null;
		
		if(jQuery("#dEndSealingDateStartDate").val()) serverData.dEndSealingDateStartDate=null;
		if(jQuery("#dEndSealingDateEndDate").val()) serverData.dEndSealingDateEndDate=null;
		
		if(jQuery("#cSealingMemo").val()) serverData.cSealingMemo=null;
		
		if(jQuery("#dTaskAcceptStorageDateStartDate").val()) serverData.dTaskAcceptStorageDateStartDate=null;
		if(jQuery("#dTaskAcceptStorageDateEndDate").val()) serverData.dTaskAcceptStorageDateEndDate=null;
		
		if(jQuery("#dTaskSubmitStorageDateStartDate").val()) serverData.dTaskSubmitStorageDateStartDate=null;
		if(jQuery("#dTaskSubmitStorageDateEndDate").val()) serverData.dTaskSubmitStorageDateEndDate=null;
		
		if(jQuery("#cTaskStorageMemo").val()) serverData.cTaskStorageMemo=null;
		
		if(jQuery("#dBeginStorageDateStartDate").val()) serverData.dBeginStorageDateStartDate=null;
		if(jQuery("#dBeginStorageDateEndDate").val()) serverData.dBeginStorageDateEndDate=null;
		
		if(jQuery("#dEndStorageDateStartDate").val()) serverData.dEndStorageDateStartDate=null;
		if(jQuery("#dEndStorageDateEndDate").val()) serverData.dEndStorageDateEndDate=null;
		
		if(jQuery("#cStorageMemo").val()) serverData.cStorageMemo=null;
    }
})();